<template>
  <!--视图部分-->
  
  <div>
      <div>购物车</div>
    <van-checkbox-group v-model="result" ref="checkboxGroup">
      <van-checkbox name="a">复选框 a</van-checkbox>
      <van-checkbox name="b">复选框 b</van-checkbox>
      <van-checkbox name="c">复选框 c</van-checkbox>
      <van-checkbox name="c">复选框 c</van-checkbox>
    </van-checkbox-group>

    <van-button type="primary" @click="checkAll">全选</van-button>
  </div>
</template>
<!--逻辑部分-->
<script>
import Vue from "vue";
import { Checkbox, CheckboxGroup } from "vant";

Vue.use(Checkbox);
Vue.use(CheckboxGroup);

export default {
  data() {
    return {
      result: [],
    };
  },
  methods: {
    checkAll() {
      this.$refs.checkboxGroup.toggleAll(true);
    },
    toggleAll() {
      this.$refs.checkboxGroup.toggleAll();
    },
  },
};
</script>
<!--样式部分-->
<style>

</style>